package game.Menus;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Vector2f;

/**
 * Vertical menu is a menu that prints all its items vertically.
 * @author Sebastian Isheden and Victor Beer
 *
 */
public class VerticalMenu extends Menu{


	/**
	 * Creates a new VerticalMenu.
	 * @param startIndex The start index.
	 * @param gap The gap between items in the menu.
	 */
	public VerticalMenu(int startIndex, int gap) {
		super(startIndex, gap);
	}
	
	/**
	 * Moves the cursor up in the menu. Moves to the bottom when it reaches the top
	 */
	public void up(){
		this.menuIndex--;
		if(this.menuIndex == -1){
			this.menuIndex = this.items.size()-1;
		}
	}
	/**
	 * Moves the cursor down in the menu. Moves to the top when it reahes the bottom.
	 */
	public void down(){
		this.menuIndex++;
		this.menuIndex = this.menuIndex % (this.items.size());
	}
	@Override
	/**
	 * Draws the menu at the given positon.
	 */
	public void draw(Vector2f startPosition, Graphics graphic) {
		int index = 0;
		for(MenuItem item : items){
			item.print(graphic, startPosition.copy().add(new Vector2f(0,index*gap)),this.menuIndex == index);
			index++;
		}
		
	}

}
